package com.ruoyi.security.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author yeoman
 * @description 证券类型枚举
 */
@Getter
@AllArgsConstructor
public enum SecurityTypeEnum {
    /**
     * 股票
     */
    STOCK("STOCK", "股票", "T1", 100, "股"),

    /**
     * ETF
     */
    ETF("ETF", "指数基金", "T1", 100, "份"),

    /**
     * 债券
     */
    BOND("BOND", "债券", "T0", 10, "张");

    private final String code;
    private final String name;
    /**
     * 结算制度
     */
    private final String settlementSystem;

    /**
     * 最小交易数量
     * 股票为100股
     * 债券为10张
     * ETF为100份
     */
    private final Integer minTradeQuantity;

     /**
      * 交易单位
      */
    private final String tradeUnit;

    public static SecurityTypeEnum getByKey(String key) {
        for (SecurityTypeEnum securityTypeEnum : SecurityTypeEnum.values()) {
            if (securityTypeEnum.getCode().equals(key)) {
                return securityTypeEnum;
            }
        }
        throw new IllegalArgumentException("不支持的证券类型 " + key);
    }

}
